package com.onedec.finance.controller;

import com.onedec.finance.entity.OnedecMaterialList;
import com.onedec.finance.servier.OnedecMaterialListService;
import com.onedec.utils.ResponseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class OnedecMaterialListController {
    @Autowired
    private OnedecMaterialListService materialListService;
    @GetMapping("selectExpend")
    public ResponseEntity selectAllMaterialList(){
        double num=0;
        List<OnedecMaterialList> lists = materialListService.selectAllMaterialList();
        if(lists.size()!=0){
            for (int i=0;i<lists.size();i++){
                num+=lists.get(i).getMaterialListTotal();
            }
            System.out.println("num"+num);
            return new ResponseEntity(num);
        }
        return new ResponseEntity("没有查询到任何的值出哦!","400");
    }
}
